/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itschapala.ds2.cafeteria.modelo;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Santiago
 */
@Entity
@Table(name = "listaplatillos")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Listaplatillos.findAll", query = "SELECT l FROM Listaplatillos l"),
    @NamedQuery(name = "Listaplatillos.findById", query = "SELECT l FROM Listaplatillos l WHERE l.id = :id"),
    @NamedQuery(name = "Listaplatillos.findByPlatillo", query = "SELECT l FROM Listaplatillos l WHERE l.platillo = :platillo"),
    @NamedQuery(name = "Listaplatillos.findByCosto", query = "SELECT l FROM Listaplatillos l WHERE l.costo = :costo"),
    @NamedQuery(name = "Listaplatillos.findByDuplicity", query = "SELECT l FROM Listaplatillos l WHERE l.platillo = :platillo")})
public class Listaplatillos implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "platillo")
    private String platillo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "costo")
    private float costo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idlistaPlatillos")
    private List<Detallecompra> detallecompraList;

    public Listaplatillos() {
    }

    public Listaplatillos(Integer id) {
        this.id = id;
    }

    public Listaplatillos(Integer id, String platillo, float costo) {
        this.id = id;
        this.platillo = platillo;
        this.costo = costo;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getPlatillo() {
        return platillo;
    }

    public void setPlatillo(String platillo) {
        this.platillo = platillo;
    }

    public float getCosto() {
        return costo;
    }

    public void setCosto(float costo) {
        this.costo = costo;
    }

    @XmlTransient
    public List<Detallecompra> getDetallecompraList() {
        return detallecompraList;
    }

    public void setDetallecompraList(List<Detallecompra> detallecompraList) {
        this.detallecompraList = detallecompraList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Listaplatillos)) {
            return false;
        }
        Listaplatillos other = (Listaplatillos) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return platillo + " " + costo;
    }
}
